package service.rocksea.com.serviceapp;

import android.util.Log;

import java.net.SocketException;

/**
 * Created by Mrw on 2017/11/4.
 *
 */

public class HeartThread extends Thread
{

    private WriteDataThread writeDataThread;
    private static boolean isTurnDown = false;

    public HeartThread(WriteDataThread writeDataThread)
    {
        this.writeDataThread = writeDataThread;
    }

    @Override
    public void run() {
        super.run();
        while (!isTurnDown)
        {
            UDPPacket udpPacket = new UDPPacket();
            try {
                writeDataThread.writePacket(udpPacket.creatJSLogin().bytes());
                sleep(8*1000);
                Log.i("HeartThread", "...");
            } catch (SocketException | InterruptedException e)
            {
                e.printStackTrace();
            }
        }
    }

    public static void turnDown()
    {
        isTurnDown = true;
    }

}
